﻿#include "window-basic-chnswitch.h"

WindowBasicChnSwitch::WindowBasicChnSwitch(QWidget *parent) : QWidget(parent)
{
    init_ctrl();
    load_skin();
    init_data();
}

void WindowBasicChnSwitch::init_ctrl()
{
    ptr_chn_bar_ = new ChnSwitchTBar(this);

    grid_lay_ = new QGridLayout();
    grid_lay_->setSpacing(5);
    int col = 0;
    for(int i = 1; i <= MAX_CHN_UNIT_NUM; i++) {
        ChnSwitchUnit* ptr = new ChnSwitchUnit(i, this);
        v_chn_units_.push_back(ptr);
        if(i <= 4) {
            col = i-1;
            grid_lay_->addWidget(ptr, 0, col,1,1);
        }
        else {
            col = i-5;
            grid_lay_->addWidget(ptr, 1, col,1,1);
        }
    }


}

void WindowBasicChnSwitch::load_skin()
{

}

void WindowBasicChnSwitch::init_data()
{

}

void WindowBasicChnSwitch::resizeEvent(QResizeEvent *event)
{
    int w = event->size().width();
    int h = event->size().height();
    int bar_h = 30;
    ptr_chn_bar_->setGeometry(0,0, w, bar_h);
    grid_lay_->setGeometry(QRect(0, bar_h, w, h-bar_h));
    event->accept();
}
